<div class="page-title">
  <h2><?php echo $page_title; ?></h2>
</div>

<?php 
  if(validation_errors()) {
  echo '<div class="error">';
    echo validation_errors(); 
  echo '</div>';
  }
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div class="grid50"><div class="rad">
  <table class="grids">
    <tbody>
      <?php if($this->uri->segment(3) == 'add') : ?>
      <tr>
        <td>ID Outlet</td>
        <td><input type="text" name="frontliner_outlet_id" value="<?php echo $outlet_id; ?>" readonly="readonly"></td>
      </tr>
    <?php endif; ?>
      <tr>
        <td>Tipe Frontliner</td>
        <td>
          <select name="frontliner_type">
            <?php 
              foreach ($complement["frontliner_type"] as $key) {
                if($key["field_val"] == $init["frontliner"]["frontliner_type"])
                  { echo '<option value="'.$key["field_val"].'" selected="selected" >'.$key["field_val"].'</option>'; }
                else
                  { echo '<option value="'.$key["field_val"].'">'.$key["field_val"].'</option>'; }
              }
            ?>
          </select>
        </td>
      </tr>
      <tr>
        <td>Nama</td>
        <td><input type="text" name="frontliner_name" size="45"></td>
      </tr>
      <tr>
        <td>Gender</td>
        <td>
          <select name="frontliner_gender">
            <?php 
              foreach ($complement["gender"] as $key) {
                if($key["field_val"] == $init["frontliner"]["frontliner_gender"])
                  { echo '<option value="'.$key["field_val"].'" selected="selected" >'.$key["field_val"].'</option>'; }
                else
                  { echo '<option value="'.$key["field_val"].'">'.$key["field_val"].'</option>'; }
              }
            ?>
          </select>
        </td>
      </tr>
      <tr>
        <td style="vertical-align: top">Alamat</td>
        <td><textarea name="frontliner_address" cols="30" rows="4" style="resize: none; font-family: inherit" ></textarea></td>
      </tr>
      <tr>
        <td>Kota</td>
        <td><input type="text" name="frontliner_city"></td>
      </tr>
      <tr>
        <td>Provinsi</td>
        <td>
          <select name="frontliner_province_id">
            <?php 
              foreach ($complement["province"] as $key) {
                if($key->province_id == $init["frontliner"]["frontliner_province_id"])
                  { echo '<option value="'.$key->province_id.'" selected="selected" >'.$key->province_name.'</option>'; }
                else
                  { echo '<option value="'.$key->province_id.'" >'.$key->province_name.'</option>'; }
              }
            ?>
          </select>
        </td>
      </tr>
      <tr>
        <td>Kode Pos</td>
        <td><input type="text" name="frontliner_zip_code"></td>
      </tr>
    </tbody>
  </table>
</div></div>

<div class="grid50"><div class="rad">
  <table class="grids">
    <tbody>
      <tr>
        <td>Agama</td>
        <td>
        <select name="frontliner_religion">
          <?php 
            foreach ($complement["religion"] as $key) {
              if($key["field_val"] == $init["frontliner"]["frontliner_religion"])
                { echo '<option value="'.$key["field_val"].'" selected="selected" >'.$key["field_val"].'</option>'; }
              else
                { echo '<option value="'.$key["field_val"].'">'.$key["field_val"].'</option>'; }
            }
          ?>
        </select>
        </td>
      </tr>
      <tr>
        <td>Tempat Lahir</td>
        <td><input type="text" name="frontliner_birth_place"></td>
      </tr>
      <tr>
        <td>Tanggal Lahir</td>
        <td><input type="text" name="frontliner_birth_date" class="datepicker" required></td>
      </tr>
      <tr>
        <td>Status Perkawinan</td>
        <td>
          <select name="frontliner_marital_status">
            <?php 
              foreach ($complement["marital_status"] as $key) {
                if($key["field_val"] == $init["frontliner"]["frontliner_marital_status"])
                  { echo '<option value="'.$key["field_val"].'" selected="selected" >'.$key["field_val"].'</option>'; }
                else
                  { echo '<option value="'.$key["field_val"].'">'.$key["field_val"].'</option>'; }
              }
            ?>
          </select>
        </td>
      </tr>
      <tr>
        <td>Tipe Identitas</td>
        <td>
          <select name="frontliner_identity_type">
            <?php 
              foreach ($complement["identity_type"] as $key) {
                if($key["field_val"] == $init["frontliner"]["frontliner_identity_type"])
                  { echo '<option value="'.$key["field_val"].'" selected="selected" >'.$key["field_val"].'</option>'; }
                else
                  { echo '<option value="'.$key["field_val"].'">'.$key["field_val"].'</option>'; }
              }
            ?>
          </select>
        </td>
      </tr>
      <tr>
        <td>Nomor Identitas</td>
        <td><input type="text" name="frontliner_identity_no" size="45"></td>
      </tr>
      <tr>
        <td>Nomor Telepon</td>
        <td><input type="text" name="frontliner_mdn_smartfren" placeholder="62xxxxx"></td>
      </tr>
      <!-- <tr>
        <td>Nmr. Operator Lain</td>
        <td><input type="text" name="frontliner_referral_sales"></td>
      </tr> -->
      <tr>
        <td style="vertical-align: top">Catatan</td>
        <td><textarea name="frontliner_remark" cols="30" rows="4" style="resize: none; font-family: inherit"></textarea></td>
      </tr>
    </tbody>
  </table>
</div></div>

<?php if($this->session->userdata('group') == 4 OR $this->session->userdata('group') == 5) : ?>
  <div class="clear"></div>
  <p class="tombol-simpan">
    <button type="submit">simpan</button>
  </p>
<?php endif; ?>

</form>

<script type="text/javascript">
  $(document).ready(function() {
    var user_group = <?php echo $this->session->userdata('group'); ?>;
    if(user_group == 4 || user_group == 5) {
      $('input').removeAttr('disabled');
      $('textarea').removeAttr('disabled');
      $('select').removeAttr('disabled');
      // $('.tombol-simpan').remove();
    }

    $('.datepicker').datepicker({
      showOn: "button",
      buttonImage: "<?php echo base_url('file/shell/smooth/resources/images/icons/calendar.png') ?>",
      buttonImageOnly: true,
      dateFormat: "yy-mm-dd",
      changeMonth: true,
      changeYear: true
    });
    $('.ui-datepicker-trigger').css({'padding-left': '4px', 'margin-top': '-4px'})
  });

</script>